<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>${applicationScope.ojName}</title>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.flat.min.css"/>
    <style>
        .main {
            width: 60%;
            margin: 0 auto;
        }

        .title {
            background: #FFF;
            border-bottom: solid 1px #CCCCCC;
            padding: 10px;
            margin-bottom: 30px;
        }

        .title h2 {
            font-size: 2em;
            width: 100%;
            text-align: center;
        }

        table {
            font-size: 15px;
        }

        .ans {
            font-weight: bolder;
        }

        .AC {
            color: #5eb95e;
        }

        .WA {
            color: #d7342e;
        }

        .other {
            color: #F37B1D;
        }

        .inf {
            text-align: center;
        }

        #page ul {
            margin-left: 0;
            margin-right: 0;
        }
    </style>
</head>

<body>

<jsp:include page="/contest/heard.html" flush="true"/>

<div class="title">
    <div class="main">
        <h2>${requestScope.contest.title} </h2>
        <p>${requestScope.contest.content}</p>
    </div>
</div>

<div class="main">
    <div class="am-panel-bd">
        <form class="am-form am-form-inline inf" action="${pageContext.request.contextPath}/contest/status.html"
              method="get">
            <input type="hidden" value="${param.page == null?"0":param.page}" name="page">
            <input type="hidden" value="${param.cid}" name="cid">
            <div class="am-input-group">
                <c:choose>
                    <c:when test="${param.pid != null}">
                        <input type="text" class="am-form-field" name="pid" placeholder="题目编号"
                               value="${param.pid}">
                    </c:when>
                    <c:otherwise>
                        <input type="text" class="am-form-field" name="pid" placeholder="题目编号">
                    </c:otherwise>
                </c:choose>
            </div>
            <div class="am-input-group">
                <c:choose>
                    <c:when test="${param.uid != null}">
                        <input type="text" class="am-form-field" name="uid" placeholder="用户"
                               value="${param.uid}">
                    </c:when>
                    <c:otherwise>
                        <input type="text" class="am-form-field" name="uid" placeholder="用户">
                    </c:otherwise>
                </c:choose>
            </div>
            <div class="am-input-group">
                <select class="lang" name="lang" title="lang">
                    <option value="-1">全部</option>
                    <option
                            <c:if test="${param.lang eq 0}">selected</c:if> value="0">C
                    </option>
                    <option
                            <c:if test="${param.lang eq 1}">selected</c:if> value="1">C++
                    </option>
                    <option
                            <c:if test="${param.lang eq 3}">selected</c:if> value="3">Java
                    </option>
                    <option
                            <c:if test="${param.lang eq 6}">selected</c:if> value="6">Python
                    </option>
                </select>
            </div>
            <div class="am-input-group">
                <select class="status" name="result" title="result">
                    <option value="-1">全部</option>
                    <option
                            <c:if test="${param.result eq 4}">selected</c:if> value="4">正确
                    </option>
                    <option
                            <c:if test="${param.result eq 6}">selected</c:if> value="6">答案错误
                    </option>
                    <option
                            <c:if test="${param.result eq 11}">selected</c:if> value="11">编译错误
                    </option>
                    <option
                            <c:if test="${param.result eq 10}">selected</c:if> value="10">运行错误
                    </option>
                    <option
                            <c:if test="${param.result eq 0}">selected</c:if> value="0">等待评测
                    </option>
                    <option
                            <c:if test="${param.result eq 5}">selected</c:if> value="5">格式错误
                    </option>
                    <option
                            <c:if test="${param.result eq 7}">selected</c:if> value="7">时间超限
                    </option>
                    <option
                            <c:if test="${param.result eq 8}">selected</c:if> value="8">内存超限
                    </option>
                    <option
                            <c:if test="${param.result eq 9}">selected</c:if> value="9">输出超限
                    </option>
                    <option
                            <c:if test="${param.result eq 1}">selected</c:if> value="1">重判中
                    </option>
                    <option
                            <c:if test="${param.result eq 2}">selected</c:if> value="2">正在编译
                    </option>
                    <option
                            <c:if test="${param.result eq 3}">selected</c:if> value="3">运行并评判
                    </option>
                    <option
                            <c:if test="${param.result eq 12}">selected</c:if> value="12">编译成功
                    </option>
                    <option
                            <c:if test="${param.result eq 13}">selected</c:if> value="13">运行完成
                    </option>
                </select>
            </div>
            <button type="submit" class="am-btn am-btn-default">查找</button>
        </form>
    </div>
    <table class="am-table am-table-striped am-table-hover am-table-bordered">
        <thead>
        <tr>
            <th>运行编号</th>
            <th>用户</th>
            <th>题目</th>
            <th>结果</th>
            <th>内存</th>
            <th>用时</th>
            <th>语言</th>
            <th>代码长度</th>
            <th>提交时间</th>
            <!--<th>判题机</th>-->
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${requestScope.list}" var="solution">
            <tr>
                <td class="rid">${solution.solution_id}</td>
                <td class="user">${solution.user_id}</td>
                <td class="promble">
                    <a href="${pageContext.request.contextPath}/problem.html?pid=${solution.problem_id}"
                       target="_blank">${solution.title}</a>
                </td>
                <td class="ans">
                    <c:choose>
                        <c:when test="${solution.result eq 4}">
                            <span class="AC">${requestScope.status[solution.result]}</span>
                        </c:when>
                        <c:when test="${solution.result eq 6}">
                            <span class="WA">${requestScope.status[solution.result]}</span>
                        </c:when>
                        <c:otherwise>
                            <span class="other">${requestScope.status[solution.result]}</span>
                        </c:otherwise>
                    </c:choose>
                </td>
                <td class="memory">${solution.memory}</td>
                <td class="time_cost">${solution.time}ms</td>
                <td class="lang">${requestScope.lang[solution.language]}</td>
                <td class="code_length">${solution.code_length} B</td>
                <td class="time">${solution.in_date}</td>
                <td class="edit">
                    <a href="#">查看</a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <div id="page"></div>
</div>

<jsp:include page="/foot.html" flush="true"/>

<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/amazeui.min.js"></script>
<script src="${pageContext.request.contextPath}/js/amazeui.page.js"></script>
<script>
    $(function () {
        $('.status').addClass('am-active');
        var page = window.location.search.match(/page=(\d+)/);
        $("#page").page({
            pages: ${requestScope.count},
            first: "首页",
            prev: '<',
            next: '>',
            groups: 0,
            curr: page ? page[1] : 1, //当前页码
            jump: "status.html?lang=${param.lang}&result=${param.result}&pid=${param.pid}&uid=${param.uid}&page=%page%"
        });
    })
</script>
</body>

</html>
<!--http://contests.acmicpc.info/contests.json-->
<!--数据来源：http://contests.acmicpc.info/contests.json-->